package com.tyqx.hashchainbiz.service.impl;

import com.tyqx.hashchainbean.module.HashIndex;
import com.tyqx.hashchainbiz.service.HashIndexService;
import com.tyqx.hashchaindao.mapper.HashIndexMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service("hashIndexService")
public class HashIndexServiceImpl implements HashIndexService {

    @Resource
    private HashIndexMapper hashIndexMapper;


    @Override
    public boolean insertHashIndex(HashIndex hashIndex) {
        hashIndex.setTxTimeStamp(new Date());
        if(hashIndexMapper.insert(hashIndex)>0){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public List<HashIndex> getHashIndexByHashValue(String hashValue) {
        return hashIndexMapper.getHashIndexByHashValue(hashValue);
    }

    @Override
    public List<String> getHashValueList(String rootHashValue) {
        return hashIndexMapper.getHashValueList(rootHashValue);
    }

    @Override
    public Integer insertBatch(List<HashIndex> hashIndexList) {
        return hashIndexMapper.insertBatch(hashIndexList);
    }
}
